package com.example.graduation.controller;

import com.example.graduation.service.impl.FileOperationServiceImpl;
import com.example.graduation.util.R;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * ProjectName gaduation
 *
 * @author xieyucan
 * <br>CreateDate 2022/4/23 2:43
 */

@RestController
@RequestMapping("/file")
public class FileController {

    @Resource
    private FileOperationServiceImpl fileOperationService;


    /**
     * @api {POST} /file/upload 文件上传
     * @apiVersion 1.0.0
     * @apiGroup FileController
     * @apiName upload
     * @apiParam (请求参数) {Object} file
     * @apiParam (请求参数) {String} token
     * @apiParamExample 请求参数示例
     * file=null&token=Na
     * @apiSuccess (响应结果) {Object} response
     * @apiSuccessExample 响应结果示例
     * {}
     */
    @PostMapping("/upload")
    public R upload(@RequestParam(value = "file") MultipartFile file, @RequestHeader String token) {
        R upload = fileOperationService.upload(file, token);
        return upload;
    }
}
